﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<link href="~/Content/css/clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet" />
<link href="~/Content/css/clockpicker/bootstrap.css" rel="stylesheet" />
<script src="~/Content/js/clockpicker/bootstrap.min.js"></script>
<script src="~/Content/js/clockpicker/bootstrap-clockpicker.min.js"></script>
<script>
    var keyValue = $.request("keyValue");
    var SiteId = $.request("SiteId");
    var site_type = $.request("site_type");
    var formid = $.request("formid");
    var filesList = [];
    var photoList = [], videoList = [];
    var PlaneFileList = [];
    var filesListDel = [];
    var photoListDel = [], videoListDel = [];
    $(function () {
        if (site_type == "114") {
            $(".ISBT").css("display", "");
            $(".SCBT").addClass("required valid");
        }
        else {
            $(".ISBT").css("display", "none");
        }
        getItemList();
        $("#F_SiteId").val(SiteId);
        if (!!keyValue) {
            $.ajax({
                url: "/SiteManage/Space/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data.spaceEntity);
                    $("#form2").formSerialize(data.marketEntity);
                    if (data.spaceEntity.F_StoreType) {
                        var F_StoreType = data.spaceEntity.F_StoreType.split(',');
                        $("#F_StoreType").val(F_StoreType).trigger("change");
                    }
                    if (data.spaceEntity.F_GuestType) {
                        var F_GuestType = data.spaceEntity.F_GuestType.split(',');
                        $("#F_GuestType").val(F_GuestType).trigger("change");
                    }
                    if (data.spaceEntity.deposit_time) {
                        $("#deposit_time1").val(data.spaceEntity.deposit_time.split('~')[0]);
                        $("#deposit_time2").val(data.spaceEntity.deposit_time.split('~')[1]);
                    }
                    if (data.spaceEntity.build_time) {
                        $("#build_time1").val(data.spaceEntity.build_time.split('~')[0]);
                        $("#build_time2").val(data.spaceEntity.build_time.split('~')[1]);
                    }

                    filesList = data.FilesList;
                    getFilesListHtml();

                    photoList = data.PhotosList;
                    getPhotoListHtml();

                    PlaneFileList = data.PlanePhotosList;

                    videoList = data.VideoList;
                    getVideoListHtml();

                    if (data.spaceEntity.F_Tags) {
                        var F_Tags = data.spaceEntity.F_Tags.split(',');
                        $("#F_Tags").val(F_Tags).trigger("change");
                    }
                    if (PlaneFileList.length > 0) {
                        $("#F_PlaneFile").css("display", "");
                        $("#F_PlaneFile").attr("src", h + PlaneFileList[0].F_path + "?v=" + RndNum(15));
                    }
                }
            });
        }
        $("#PhotoFile").change(function () {
            $("#displaydiv").empty();
            for (var i = 0, j = this.files.length; i < j; i++) {
                $("#displaydiv").append("<img name='" + this.files[i].name + "'  src=\"" + window.URL.createObjectURL(this.files[i]) + "\">");
            }
        });
    });

    function getDepositTime(type, sid) {
        var stime = $("#" + sid + "1").val();
        var etime = $("#" + sid + "2").val();
        if (type == 1 && stime != "" && etime == "") {
            $("#" + sid + "2").val(stime);
        }
        else if (type == 1 && stime == "") {
            $("#" + sid + "2").val("");
        }
        else if (type == 2 && stime == "") {
            $("#" + sid + "1").val(etime);
        }
        else if (type == 2 && etime == "") {
            $("#" + sid + "1").val("");
        }
        $("#" + sid).val($("#" + sid + "1").val() + "~" + $("#" + sid + "2").val())
        if (stime == "" && etime == "") {
            $("#" + sid).val("")
        }
    }

    //动态获取文件HTML
    function getFilesListHtml() {
        $("#imgrq").empty();
        for (var i = 0, j = filesList.length; i < j; i++) {
            var url = "";
            url = h + filesList[i].F_path + "?v=" + RndNum(14);
            $("#imgrq").append("<div style='float:left;margin-right:30px;'><a target='_blank' href='" + url + "'>" +
                filesList[i].name + "</a><a class='filedel' onclick=\"btn_delete_files('" + filesList[i].F_Id + "','SpaceFiles')\">删除</a></div>");
        }
    }
    var h = "http://storage.yunspace.com.cn/";
    //动态获取图片HTML
    function getPhotoListHtml() {
        $("#photoList").empty();
        for (var i = 0; i < photoList.length; i++) {
            var cha = "", is_Emphasis = "";
            if (photoList[i].is_cover) {
                cha = "checked";
            }
            if (photoList[i].F_IsEmphasis) {
                is_Emphasis = "checked";
            }
            var url = "", bigurl = "";
            url = h + photoList[i].F_path + "-120x120?v=" + RndNum(14);
            bigurl = h + photoList[i].F_path + "?v=" + RndNum(14);
            $("#photoList").append("<div class='imgList'><div class='imglink' id='" + i
                + "' onclick='checkDownload(this.id)'><input type='checkbox' class='isDownload' id='Down" + i
                + "' name= 'isDownload' value= '" + i + "' ><img id='img" + photoList[i].F_Id
                + "' style= 'width:120px; height:100px;' /></div><div><input type='text' id='"
                + photoList[i].F_Id + "' class='form-control imgtag' onChange=\"uptag('" + photoList[i].F_Id + "', this.value,photoList)\" value='" + photoList[i].tag
                + "' placeholder='参考：外观图1 / 控制台' /><input type='radio' class='rdio' " + cha + " id='radio" + photoList[i].F_Id
                + "' name='is_cover' value='" + photoList[i].F_Id + "' />首图<a class='photodel' onclick=\"btn_delete_files('"
                + photoList[i].F_Id + "','photoList')\">删除</a><br><input type='checkbox' " + is_Emphasis + " id='checkbox" + photoList[i].F_Id
                + "' name='is_Emphasis' value='" + photoList[i].F_Id + "' />重点<a class='big_photo' target='_blank'  href='" + bigurl + "'>大图</a></div></div >");
            $("#img" + photoList[i].F_Id).attr('src', src = url);
        }
    }
    //动态获取小视频HTML
    function getVideoListHtml() {
        $("#VideoList").empty();
        for (var i = 0; i < videoList.length; i++) {
            var cha = "", is_Emphasis = "";
            if (videoList[i].is_cover) {
                cha = "checked";
            }
            var url = "";
            url = h + videoList[i].F_path + "?v=" + RndNum(14);
            $("#VideoList").append("<div class='video'><video style= 'width:150px; height:220px;' src='" + url + "' controls preload='auto'></video ><div><input type='text' id='"
                + videoList[i].F_Id + "' class='form-control videotag' onChange=\"uptag('" + videoList[i].F_Id + "', this.value,videoList)\" value='" + videoList[i].tag
                + "' placeholder='参考：外观图1 / 控制台' /><input type='radio' class='rdio' " + cha + " id='radio" + videoList[i].F_Id
                + "' name='videois_cover' value='" + videoList[i].F_Id + "' />优选<a class='photodel' onclick=\"btn_delete_files('"
                + videoList[i].F_Id + "','SpaceVideo')\">删除</a></div></div >");
        }
    }
    function checkDownload(id) {
        document.getElementById("Down" + id).checked = document.getElementById("Down" + id).checked ? false : true;
    }

    function downloadImage(src) {
        var $a = $("<a></a>").attr("href", src).attr("download", "meitu.png");
        $a[0].click();
    }
    var is_Down = 0;
    //是否重点图片
    function checkIsDown() {
        if (photoList.length > 0) {
            var $selectedvalue = $("input[name='isDownload']");
            for (var i = 0; i < photoList.length; i++) {
                if ($selectedvalue[i].checked && i == $selectedvalue[i].value) {
                    is_Down += 1;
                    downloadImage(h + photoList[i].F_path);
                }
            }
        } else {
            $.modalAlert("请先上传空间图片!", "warning");
        }
        if (is_Down == 0) {
            $.modalAlert("请先点击图片选择您要下载的项目!", "warning");
        }
    }
    var is_ThereCover = false;
    var is_ThereEmphasis = 0;
    //获取首图
    function rdioIs_Cover() {
        if (photoList.length > 0) {
            var $selectedvalue = $("input[name='is_cover']:checked").val();
            $selectedvalue = $selectedvalue == undefined ? "" : $selectedvalue;
            for (var i = 0; i < photoList.length; i++) {
                if (photoList[i].F_Id == $selectedvalue) {
                    is_ThereCover = true;
                    photoList[i].is_cover = true;
                }
                else {
                    photoList[i].is_cover = false;
                }
            }
        }
    }
    //是否重点图片
    function checkF_IsEmphasis() {
        is_ThereEmphasis = 0;
        if (photoList.length > 0) {
            var $selectedvalue = $("input[name='is_Emphasis']");
            for (var i = 0; i < photoList.length; i++) {
                if ($selectedvalue[i].checked && photoList[i].F_Id == $selectedvalue[i].value) {
                    is_ThereEmphasis += 1;
                    photoList[i].F_IsEmphasis = true;
                }
                else {
                    photoList[i].F_IsEmphasis = false;
                }
            }
        }
    }

    var videois_ThereCover = false;
    //获取优选视频
    function VideoIs_Cover() {
        if (videoList.length > 0) {
            var $selectedvalue = $("input[name='videois_cover']:checked").val();
            $selectedvalue = $selectedvalue == undefined ? "" : $selectedvalue;
            for (var i = 0; i < videoList.length; i++) {
                if (videoList[i].F_Id == $selectedvalue) {
                    videois_ThereCover = true;
                    videoList[i].is_cover = true;
                }
                else {
                    videoList[i].is_cover = false;
                }
            }
        }
    }
    //修改图片tag
    function uptag(F_Id, value, list) {
        for (var i = 0; i < list.length; i++) {
            if (list[i].F_Id == F_Id) {
                list[i].tag = value;
                break;
            }
        }
    }

    //删除单个资料文件
    function btn_delete_files(F_Id, type) {
        if ($("#title").val() != "") {
            if (type == "SpaceFiles") {
                $("#imgrq").empty();
                if (filesList.length > 0) {
                    for (var i = 0; i < filesList.length; i++) {
                        if (filesList[i].F_Id == F_Id) {
                            if (filesList[i].F_Id.length > 4) {
                                filesList[i].F_DeleteMark = true;
                                filesListDel.push(filesList[i])
                            }
                            RemoveValByIndex(filesList, i);
                        }
                    }
                    getFilesListHtml();
                }
            }
            else if (type == "SpaceVideo") {
                $("#VideoList").empty();
                if (videoList.length > 0) {
                    for (var i = 0; i < videoList.length; i++) {
                        if (videoList[i].F_Id == F_Id) {
                            if (videoList[i].F_Id.length > 4) {
                                videoList[i].F_DeleteMark = true;
                                videoListDel.push(videoList[i])
                            }
                            RemoveValByIndex(videoList, i);
                        }
                    }
                    VideoIs_Cover();
                    getVideoListHtml();
                }
            }
            else {
                rdioIs_Cover();
                checkF_IsEmphasis();
                $("#photoList").empty();
                var plist = photoList;
                if (plist.length > 0) {
                    for (var i = 0; i < photoList.length; i++) {
                        if (photoList[i].F_Id == F_Id) {
                            if (photoList[i].F_Id.length > 4) {
                                photoList[i].F_DeleteMark = true;
                                photoListDel.push(photoList[i])
                            }
                            RemoveValByIndex(photoList, i);
                        }
                    }
                    getPhotoListHtml();
                }
            }
        }
        else {
            $.modalAlert("请先填写空间基础数据！", "warning");
        }
    }
    var xhr;
    var cvalue = "";
    var bigvlue = "";


    var myDate = new Date();
    var mytime = myDate.getFullYear().toString() + myDate.getMonth().toString() + myDate.getDate().toString();


    //批量上传资料文件
    function uploadSend(actionId, type) {
        cvalue = "";
        bigvlue = ""; imgWidthType = "";
        var big = type == "SpaceFiles" ? 30 : 10;
        if ($("#title").val() != "") {
            var data = new FormData();
            var item = document.getElementById(actionId);
            if (item != null && item.files.length > 0) {
                var files = item.files;
                if (type == "SpaceFiles") {
                    var fid = files.length;
                    bigvlue = "";
                    for (var i = 0; i < files.length; i++) {
                        var file = item.files[i];
                        fileSize = file.size;
                        fileSize = Math.round(fileSize / 1024 * 100) / 100; //kb
                        if (fileSize > 30720) {
                            bigvlue += file.name + ' ';
                        } else {
                            data.append(file.name, file);
                            filesList.push({
                                name: file.name,
                                F_Id: fid + i,
                                tag: '',
                                is_cover: false,
                                F_IsEmphasis: false,
                                photoable_type: type,
                                F_path: "uploads/files/path/" + mytime + "/" + file.name
                            });
                        }
                    }
                }
                else if (type == "SpacePlaneFile") {
                    var file = item.files[0];
                    fileSize = file.size;
                    fileSize = Math.round(fileSize / 1024 * 100) / 100; //kb
                    if (fileSize > 10240) {
                        $.modalAlert("图片超出超过了限制大小,请上传10MB内的文件", "warning");
                        return false;
                    } else {
                        data.append(file.name, file);
                        var fid = '';
                        if (PlaneFileList != null && PlaneFileList.length > 0) {
                            fid = PlaneFileList[0].F_Id;
                        }
                        PlaneFileList[0] = {
                            name: file.name,
                            F_Id: fid,
                            tag: '空间平面图',
                            is_cover: false,
                            F_IsEmphasis: false,
                            photoable_type: type,
                            F_path: "uploads/files/path/" + mytime + "/" + file.name
                        };
                    }
                }
                else if (type == "SpaceVideo") {
                    var fid = videoList.length;
                    bigvlue = "";
                    for (var i = 0; i < files.length; i++) {
                        var file = item.files[i];
                        fileSize = file.size;
                        fileSize = Math.round(fileSize / 1024 * 100) / 100; //kb
                        if (fileSize > 10240) {
                            bigvlue += file.name + ' ';
                        } else {
                            data.append(file.name, file);
                            videoList.push({
                                name: file.name,
                                F_Id: fid + i,
                                tag: '',
                                is_cover: false,
                                F_IsEmphasis: false,
                                photoable_type: type,
                                F_path: "uploads/files/path/" + mytime + "/" + file.name
                            });
                        }
                    }
                }
                else {
                    var fid = photoList.length;
                    for (var i = 0; i < files.length; i++) {
                        var file = item.files[i];
                        fileSize = file.size;
                        fileSize = Math.round(fileSize / 1024 * 100) / 100; //kb
                        if (createReader(i)) {
                            if (fileSize > 10240) {
                                bigvlue += file.name + ' ';
                            } else {
                                data.append(file.name, file);
                                photoList.push({
                                    name: file.name,
                                    F_Id: fid + i,
                                    tag: '',
                                    is_cover: false,
                                    F_IsEmphasis: false,
                                    photoable_type: type,
                                    F_path: "uploads/files/path/" + mytime + "/" + file.name
                                })
                            }
                        }
                    }
                }
                $.loading(true, "文件正在上传中，请稍后...");
                xhr = new XMLHttpRequest();
                xhr.onload = function () {
                    data = JSON.parse(xhr.responseText);
                    if (data.state == 1) {
                        if (imgWidthType != "") {
                            $.modalAlert(imgWidthType, "warning");
                        }
                        else if (cvalue != "" && bigvlue != "") {
                            $.modalAlert(cvalue + "图片比例不对，请提供长宽比为4:3的常规横向展示照片," + bigvlue + " 超过了限制大小,请上传" + big + "MB内的文件", "warning");
                        }
                        else if (bigvlue != "") {
                            $.modalAlert(bigvlue + " 超过了限制大小,请上传" + big + "MB内的文件", "warning");
                        }
                        else if (cvalue != "") {
                            $.modalAlert(cvalue + "图片比例不对，请提供长宽比为4:3的常规横向展示照片", "warning");
                        } else {
                            $.modalAlert("资料保存成功!", "warning");
                        }
                        var file = document.getElementById(actionId);
                        file.value = "";
                    } else {
                        if (imgWidthType != "") {
                            $.modalAlert(imgWidthType, "warning");
                        }
                        else if (cvalue != "" && bigvlue != "") {
                            $.modalAlert(cvalue + "图片比例不对，请提供长宽比为4:3的常规横向展示照片," + bigvlue + " 超过了限制大小,请上传" + big + "MB内的文件", "warning");
                        }
                        else if (bigvlue != "") {
                            $.modalAlert(bigvlue + " 超过了限制大小,请上传" + big + "MB内的文件", "warning");
                        }
                        else if (cvalue != "") {
                            $.modalAlert(cvalue + "图片比例不对，请提供长宽比为4:3的常规横向展示照片", "warning");
                        } else {
                            $.modalAlert("上传失败！", "warning");
                        }
                        $.loading(false, "");
                    }
                    if (type == "Space") {
                        getPhotoListHtml();
                    }
                    else if (type == "SpaceFiles") {
                        getFilesListHtml();
                    }
                    else if (type == "SpaceVideo") {
                        getVideoListHtml();
                    } else if (type == "SpacePlaneFile") {
                        if (PlaneFileList != null && PlaneFileList.length > 0) {
                            $("#F_PlaneFile").css("display", "");
                            $("#F_PlaneFile").attr("src", h + PlaneFileList[0].F_path + "?v=" + RndNum(15));
                        }
                    }
                    $.loading(false, "");
                };
                xhr.onerror = function (err) {
                    console.error(err);
                    $.loading(false, "");
                };
                xhr.open('post', '/SiteManage/Site/UploadPathFiles?sitename=' + mytime + '&type=' + type, true);
                console.log(data);
                xhr.send(data);
            }
            else {
                $.modalAlert("请先选择您要上传的文件！", "warning");
            }
        }
        else {
            $.modalAlert("请先填写空间基础数据！", "warning");
        }
    }


    var imgWidthType = "";
    function createReader(i) {
        var divs = document.getElementById("displaydiv");
        var imgs = divs.getElementsByTagName("img");
        if (imgs.length > 0) {
            var w = imgs[i].width;
            var h = imgs[i].height;
            if (w < h) {
                imgWidthType += imgs[i].name + "图片比例不正确";
                return false;
            }
            else if (w < 790 || h < 526) {
                imgWidthType += imgs[i].name + "图片过小,最小尺寸（790*526）";
                return false;
            }
            else {
                return true;
            }
        }
    }

    function getItemList() {
        $.ajax({
            url: "/SiteManage/Site/GetItemListJson",
            dataType: "json",
            async: false,
            success: function (data) {
                initControl(data)
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function initControl(ItemList) {
        var SiteState = ItemList.SiteState;
        for (var i = 0; i < SiteState.length; i++) {
            $("#state").append("<option value='" + SiteState[i].F_ItemCode + "'>" + SiteState[i].F_ItemName + "</option>");
        }
        $("#state").bindSelect()//上线状态
        var units = ItemList.units
        for (var i = 0; i < units.length; i++) {
            $("#units").append("<option value='" + units[i].F_ItemCode + "'>" + units[i].F_ItemName + "</option>");
        }
        $("#units").bindSelect()//价格单位

        var Subscription_Type = ItemList.Subscription_Type
        for (var i = 0; i < Subscription_Type.length; i++) {
            $("#F_Subscription_Type").append("<option value='" + Subscription_Type[i].F_ItemCode + "'>" + Subscription_Type[i].F_ItemName + "</option>");
        }
        //使用特点
        var SiteTrait = ItemList.SiteTrait;
        for (var i = 0; i < SiteTrait.length; i++) {
            $("#F_Tags").append("<option value='" + SiteTrait[i].F_ItemCode + "'>" + SiteTrait[i].F_ItemName + "</option>");
        }
        //人均消费
        var AverageConsumer = ItemList.AverageConsumer;
        for (var i = 0; i < AverageConsumer.length; i++) {
            $("#F_Average_Consumer").append("<option value='" + AverageConsumer[i].F_ItemCode + "'>" + AverageConsumer[i].F_ItemName + "</option>");
        }
        //商场定位
        var StoreType = ItemList.StoreType;
        for (var i = 0; i < StoreType.length; i++) {
            $("#F_StoreType").append("<option value='" + StoreType[i].F_ItemCode + "'>" + StoreType[i].F_ItemName + "</option>");
        }
        //客群定位
        var GuestType = ItemList.GuestType;
        for (var i = 0; i < GuestType.length; i++) {
            $("#F_GuestType").append("<option value='" + GuestType[i].F_ItemCode + "'>" + GuestType[i].F_ItemName + "</option>");
        }
        $("#F_Tags").bindSelect({
            multiple: true
        });
        $("#F_Average_Consumer").bindSelect();
        $("#F_StoreType").bindSelect();
        $("#F_GuestType").bindSelect();
        $("#F_Subscription_Type").bindSelect();//订金收取方式

        //加载下拉控件
        $("#quote_explain").bindSelect();
        $("#through_three_areas").bindSelect();
        $("#vehicle").bindSelect();
        $("#Is_night_build").bindSelect();
        $("#pair").bindSelect();
        $("#vehicle").bindSelect();


        var units = ItemList.units;
        for (var i = 0; i < units.length; i++) {
            $("#F_Units").append("<option value='" + units[i].F_ItemCode + "'>" + units[i].F_ItemName + "</option>");
        }
        var reservationWay = ItemList.ReservationWay;
        for (var i = 0; i < reservationWay.length; i++) {
            $("#F_ReservationWay").append("<option value='" + reservationWay[i].F_ItemCode + "'>" + reservationWay[i].F_ItemName + "</option>");
        }
        $("#F_Units").bindSelect();//价格单位
        $("#F_ReservationWay").bindSelect();//预定方式

        $("#F_IsNightPlays").bindSelect();//可否通宵搭建
    }
    function submitForm() {

        var ListInfo = [];
        ListInfo = photoList;
        rdioIs_Cover();
        checkF_IsEmphasis();
        VideoIs_Cover();
        var form1value = $("#form1").formSerialize();

        if (!$('#form1').formValid() || !$('#form2').formValid()) {
            $.modalAlert("必填项目未填写完整，请检查后再次提交!", "warning");
            return false;
        }
        if (!form1value.F_Tags && form1value.F_Tags.length <= 0) {
            $.modalAlert("请先选择空间标签!", "warning");
            return false;
        }
        if (photoList.length >= 3 && photoList.length < 11) {
            if (!is_ThereCover) {
                $.modalAlert("请先设置空间显示首图！", "warning");
                return false;
            }
            if (is_ThereEmphasis != 3) {
                $.modalAlert("请先设置空间重点图三张！", "warning");
                return false;
            }
        }
        else {
            $.modalAlert("空间图片请控制3-10张哦!", "warning");
        }

        //空间标签
        if (form1value.F_Tags && form1value.F_Tags.length > 0) {
            form1value.F_Tags = form1value.F_Tags.join(',');
        } else {
            form1value.F_Tags = "";
        }
        //需要从数据库删除的图片数据
        for (var i = 0; i < photoListDel.length; i++) {
            ListInfo.push(photoListDel[i]);
        }
        //需要更新或修改的附件数据
        for (var i = 0; i < filesList.length; i++) {
            ListInfo.push(filesList[i]);
        }
        //需要从数据库删除的附件数据
        for (var i = 0; i < filesListDel.length; i++) {
            ListInfo.push(filesListDel[i]);
        }
        //需要更新或修改的视频数据
        for (var i = 0; i < videoList.length; i++) {
            ListInfo.push(videoList[i]);
        }
        //需要从数据库删除的视频数据
        for (var i = 0; i < videoListDel.length; i++) {
            ListInfo.push(videoListDel[i]);
        }
        if (PlaneFileList.length > 0) {
            ListInfo.push(PlaneFileList[0]);
        }
        var params = {
            spaceOutput: JSON.stringify({
                spaceEntity: form1value,//空间信息
                marketEntity: $("#form2").formSerialize(),//商场信息
                photosList: ListInfo//图片
            })
        };
        $.ajax({
            url: "/SiteManage/Space/SubmitForm?keyValue=" + keyValue,
            dataType: "json",
            type: 'post',
            data: params,
            async: false,
            success: function (data) {
                if (data.state == "success") {
                    $.modalAlert("空间信息提交成功!", "warning");
                    if (formid.length > 12) {
                        formid = "iframe" + formid;
                        top.frames[formid].window.$("#Space_gridList").trigger("reloadGrid");
                        $.modalFrameClose(window.name);
                    } else {
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                        $.modalFrameClose(top.frames[formid].window.name);
                        $.modalFrameClose(window.name);
                    }
                } else {
                    $.modalAlert("信息提交失败，请联系管理员!", "warning");
                }
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function chanc() {
        var market = $("#F_MarketPrice").val();
        var floor = $("#F_FloorPrice").val();
        if (market != "" && floor != "" && market > 0 && floor > 0) {
            var value = (market - floor) / market;
            $("#porfit_rate").val(value);
        }
    }

</script>

<style>
    input {
        font-size: 12px !important;
    }

    .formTitle {
        font-size: 12px !important;
        width: 197px !important;
    }

    .filedel {
        margin-left: 20px;
        color: red;
    }

    .photodel {
        margin-left: 40px;
        color: red;
    }

    .big_photo {
        margin-left: 40px;
        color: dimgrey;
    }

    .imgtag {
        width: 120px !important;
        height: 20px !important;
        text-align: center;
        margin-top: 10px;
    }

    .videotag {
        width: 150px !important;
        height: 20px !important;
        text-align: center;
        margin-top: 10px;
    }

    .video {
        float: left;
        width: 150px;
        height: 260px;
        margin: 10px;
        text-align: left;
    }

    #photoList {
        margin-left: 40px;
        height: 190px;
    }

        #photoList .imglink {
            position: relative;
            cursor: pointer;
            height: 100px;
            width: 120px;
        }


    .isDownload {
        position: absolute;
        right: 5px;
        top: 5px;
    }

    .imgList {
        float: left;
        width: 120px;
        height: 170px;
        margin: 10px;
        text-align: left;
    }

    .input-group-addon {
        padding: 5px 8px;
    }
</style>
<form id="form1">
    <table class="form">
        <tr>
            <td colspan="6" class="interval">空间信息</td>
        </tr>
        <tr>
            <th class="formTitle">空间名称<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="title" name="title" type="text" class="form-control required" maxlength="40" placeholder="请录入空间名称" />
                <input id="F_SiteId" name="F_SiteId" disabled="disabled" type="hidden" />
            </td>
            @*<th class="formTitle">上线状态<span style="color:red">*</span></th>
                <td class="formValue">
                    <select id="state" name="state" class="form-control required">
                    </select>
                </td>*@
        </tr>
        <tr>
            <th class="formTitle">可使用面积（平米）<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="area" name="area" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control required" placeholder="参考填写：300" />
            </td>
            <th class="formTitle">空间层高（米）<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="height" name="height" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control required" placeholder="参考填写：6" />
            </td>
            <th class="formTitle">可搭建高度(米)</th>
            <td class="formValue">
                <input id="limit_height" name="limit_height" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入可搭建高度" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">长*宽(米）(秀场必填)</th>
            <td class="formValue">
                <input id="length_width" name="length_width" type="text" maxlength="20" class="form-control" placeholder="参考填写：50*40" />
            </td>
            <th class="formTitle">地面称重（KG/平米）</th>
            <td class="formValue">
                <input id="accept_weight" name="accept_weight" type="text" maxlength="20" class="form-control" placeholder="参考填写：300" />
            </td>
            <th class="formTitle">最大容纳人数（人）<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="max_seating_capacity" name="max_seating_capacity" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control required" placeholder="参考填写：500" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">落位区域<span style="color:red">*</span></th>
            <td class="formValue">
                <select id="through_three_areas" name="through_three_areas" class="form-control required">
                    <option value="">==请选择==</option>
                    <option value="室内">室内</option>
                    <option value="室外">室外</option>
                    <option value="半开放式">半开放式</option>
                </select>
            </td>
            <th class="formTitle">所处楼层<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="current_floor" name="current_floor" type="text" maxlength="10" class="form-control required" placeholder="参考填写：B1/B2/1F/2F" />
            </td>
            <th class="formTitle">次级落位区域</th>
            <td class="formValue">
                <input id="F_SecondaryCurrent" name="F_SecondaryCurrent" type="text" maxlength="100" class="form-control" placeholder="参考填写:连廊,中庭,停车场,正门入口处 等" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">可否进车<span style="color:red">*</span></th>
            <td class="formValue">
                <select id="vehicle" name="vehicle" class="form-control required">
                    <option value="">==请选择==</option>
                    <option value="是">是</option>
                    <option value="否">否</option>
                </select>
            </td>
            <th class="formTitle">进出口限高（米）</th>
            <td class="formValue">
                <input id="exit_limit" name="exit_limit" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写：5" />
            </td>
            <th class="formTitle">进出口限宽（米）</th>
            <td class="formValue">
                <input id="exit_width" name="exit_width" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写：5" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">空间吊顶(KG/个)</th>
            <td class="formValue">
                <input id="ceiling" name="ceiling" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写：200" />
            </td>
            <th class="formTitle">吊点数(个)</th>
            <td class="formValue">
                <input id="some_digits" name="some_digits" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写：10" />
            </td>
            <th class="formTitle">最大吊点总承重数（KG）</th>
            <td class="formValue">
                <input id="largest_digits" name="largest_digits" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写：500" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">供电量(千瓦)</th>
            <td class="formValue">
                <input id="power_supply" name="power_supply" type="text" maxlength="30" class="form-control" placeholder="参考填写：200" />
            </td>
            <th class="formTitle">网络(兆)</th>
            <td class="formValue">
                <input id="network" name="network" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写：500" />
            </td>
            <th class="formTitle">固定的座位数（个）</th>
            <td class="formValue">
                <input id="Fixed_Seat_Number" name="Fixed_Seat_Number" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写：3000" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">平日人流量<span class="ISBT" style="color:red">*</span></th>
            <td class="formValue"><input id="visitors" name="visitors" type="text" maxlength="20" class="SCBT form-control " placeholder="参考填写：50000" /></td>
            <th class="formTitle">周末人流量<span class="ISBT" style="color:red">*</span></th>
            <td class="formValue"><input id="weekend_flow" name="weekend_flow" type="text" maxlength="20" class="SCBT form-control " placeholder="参考填写：70000" /></td>
        </tr>
        <tr>
            <th class="formTitle">可进场时间段</th>
            <td class="formValue">
                <div class="input-group clockpicker" style="width:50%;float:left;" data-autoclose="true">
                    <input id="deposit_time1" onchange="getDepositTime(1,'deposit_time')" name="deposit_time1" maxlength="10" type="text" class="form-control" placeholder="开始时间">
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-time"></span>
                    </span>
                </div>
                <div class="input-group clockpicker" style="width:50%;float:left;" data-autoclose="true">
                    <input id="deposit_time2" name="deposit_time2" onchange="getDepositTime(2,'deposit_time')" maxlength="10" type="text" class="form-control" placeholder="结束时间">
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-time"></span>
                    </span>
                </div>
                <input id="deposit_time" name="deposit_time" type="hidden">
            </td>
            <th class="formTitle">可搭建时间</th>
            <td class="formValue">
                <div class="input-group clockpicker" style="width:50%;float:left;" data-autoclose="true">
                    <input id="build_time1" name="build_time1" type="text" onchange="getDepositTime(1,'build_time')" maxlength="10" class="form-control" placeholder="开始时间">
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-time"></span>
                    </span>
                </div>
                <div class="input-group clockpicker" style="width:50%;float:left;" data-autoclose="true">
                    <input id="build_time2" name="build_time2" type="text" onchange="getDepositTime(2,'build_time')" maxlength="10" class="form-control" placeholder="结束时间">
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-time"></span>
                    </span>
                </div>
                <input id="build_time" name="build_time" type="hidden">
            </td>
            @*<th class="formTitle">是否可以通宵搭建</th>
                <td class="formValue">
                    <select id="Is_night_build" name="Is_night_build" class="form-control">
                        <option value="">==请录入是否可以通宵搭建==</option>
                        <option value="true">是</option>
                        <option value="false">否</option>
                    </select>
                </td>*@
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 5px;">
                曾做过的活动
            </th>
            <td class="formValue" colspan="5">
                <textarea id="past_activities" name="past_activities" class="form-control" maxlength="600" style="height: 60px;" placeholder="参考输入：保时捷汽车展 | 雪佛兰汽车展 | 某某大型服装秀"></textarea>
            </td>
        </tr>
        <tr>
            <th class="formTitle">空间标签<span style="color:red">*</span></th>
            <td class="formValue" colspan="5">
                <select id="F_Tags" name="F_Tags" class="form-control required" multiple="multiple"></select>
            </td>
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 5px;">
                空间介绍<span style="color:red">*</span>
            </th>
            <td class="formValue" colspan="5">
                <textarea id="introduced" name="introduced" class="form-control required" maxlength="600" style="height: 60px;" placeholder="参考填写：黑色无柱空间，可进车，适合举办各类时尚发布活动"></textarea>
            </td>
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 5px;">活动现场禁忌</th>
            <td class="formValue" colspan="5">
                <textarea id="remark" name="remark" type="text" class="form-control" maxlength="150" style="height:65px" placeholder="参考填写：截止房产类活动，亲子类活动，餐饮类油烟活动，地面必须保护覆盖等"></textarea>
            </td>
        </tr>
        <tr>
            <td colspan="6" class="interval">价格相关</td>
        </tr>
        <tr>
            <th class="formTitle">价格是否含税<span style="color:red">*</span></th>
            <td class="formValue">
                <select id="quote_explain" name="quote_explain" class="form-control required">
                    <option value="">==请录入价格是否含税==</option>
                    <option value="1">含税</option>
                    <option value="0">不含税</option>
                </select>
            </td>
            <th class="formTitle">税点（%）</th>
            <td class="formValue">
                <input id="c_month_price" name="c_month_price" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="如不含税请输入，参考填写：6" />
            </td>
            <th class="formTitle">进场押金（元）</th>
            <td class="formValue">
                <input id="deposit" name="deposit" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写：30000" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">利润率(%)</th>
            <td class="formValue">
                <input id="porfit_rate" name="porfit_rate" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入利润率" />
            </td>
            <td class="formTitle">订金收取方式：</td>
            <td class="formValue">
                <select id="F_Subscription_Type" name="F_Subscription_Type" class="form-control">
                    <option value="">==请录入订金收取方式==</option>
                </select>
            </td>
            <td class="formTitle">订金金额：</td>
            <td class="formValue">
                <input id="F_Subscription_Price" name="F_Subscription_Price" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入订金金额" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">价格单位<span style="color:red">*</span></th>
            <td class="formValue">
                <select id="F_Units" name="F_Units" class="form-control required"></select>
            </td>
            <th class="formTitle">超人加收(元/人)</th>
            <td class="formValue">
                <input id="F_BeyondPersonnel" name="F_BeyondPersonnel" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入超人加收元人" />
            </td>
            <th class="formTitle">超时加收(元/时)</th>
            <td class="formValue">
                <input id="F_BeyondTime" name="F_BeyondTime" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入超时加收元时" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">周末市场刊例价<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="F_MarketPrice" name="F_MarketPrice" type="number" oninput="if(value.length>8)value=value.slice(0,8)" onchange="chanc()" class="form-control required" placeholder="请录入市场价格" />
            </td>
            <th class="formTitle">周末YUNSPACE价<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="F_YunPrice" name="F_YunPrice" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control required" placeholder="请录入云space价格" />
            </td>
          
        </tr>
        <tr>
            <th class="formTitle">平日市场刊例价<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="F_ordinary_MarketPrice" name="F_ordinary_MarketPrice" type="number" oninput="if(value.length>8)value=value.slice(0,8)" onchange="chanc()" class="form-control required" placeholder="请录入市场价格" />
            </td>
            <th class="formTitle">平日YUNSPACE价<span style="color:red">*</span></th>
            <td class="formValue">
                <input id="F_ordinary_YunPrice" name="F_ordinary_YunPrice" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control required" placeholder="请录入云space价格" />
            </td>
           
        </tr>
        <tr>
            <th class="formTitle">搭建日市场刊例价</th>
            <td class="formValue">
                <input id="F_PriceMarketBuild" name="F_PriceMarketBuild" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入搭建日市场刊例价" />
            </td>
            <th class="formTitle">搭建日YUNSPACE价</th>
            <td class="formValue">
                <input id="F_PriceBuild" name="F_PriceBuild" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入搭建日Yunspace价" />
            </td>
           
        </tr>
        @*<tr>
                <th class="formTitle">可否通宵搭建</th>
                <td class="formValue">
                    <select id="F_IsNightPlays" name="F_IsNightPlays" class="form-control">
                        <option value="false">否</option>
                        <option value="true">是</option>
                    </select>
                </td>
                <td colspan="4"></td>
            </tr>*@
        <tr>
            <th class="formTitle">通宵搭建市场刊例价</th>
            <td class="formValue">
                <input id="F_PriceNightMarketBuild" name="F_PriceNightMarketBuild" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入通宵搭建市场刊例价" />
            </td>
            <th class="formTitle">通宵搭建YUNSPACE价</th>
            <td class="formValue">
                <input id="F_PriceNightBuild" name="F_PriceNightBuild" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="请录入通宵搭建Yunspace价" />
            </td>
          
        </tr>
        <tr>
            <th class="formTitle">能耗说明（电费）</th>
            <td class="formValue">
                <input id="F_PropertyFee" name="F_PropertyFee" type="text" class="form-control" placeholder="参考填写：2元/度" />
                @*<select id="F_PropertyFee" name="F_PropertyFee" class="form-control"></select>*@
            </td>
            <th class="formTitle">能耗说明（水费）</th>
            <td class="formValue">
                <input id="F_CostWater" name="F_CostWater" type="text" class="form-control" placeholder="参考填写：5元/立方米" />
                @*<select id="F_CostWater" name="F_CostWater" class="form-control"></select>*@
            </td>
            <th class="formTitle">能耗说明（网费）</th>
            <td class="formValue">
                <input id="F_CostNetwork" name="F_CostNetwork" type="text" class="form-control" placeholder="参考填写：2000元/场（100兆）" />
                @*<select id="F_CostNetwork" name="F_CostNetwork" class="form-control"></select>*@
            </td>
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 5px;">
                其他费用
            </th>
            <td class="formValue" colspan="5">
                <textarea id="F_OtherPrice" name="F_OtherPrice" maxlength="500" class="form-control" style="height: 60px;" placeholder="参考填写： 空调费2000元/12小时#大厅LED2000元/场 （如有多个项目价格，请以#区分 ）"></textarea>
            </td>
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 5px;">
                价格备注
            </th>
            <td class="formValue" colspan="5">
                <textarea id="F_PriceDes" name="F_PriceDes" maxlength="500" class="form-control" style="height: 60px;" placeholder="参考填写：如以上价格有特别适用情况，可在此备注"></textarea>
            </td>
        </tr>
    </table>
</form>
<form id="form2">
    <table class="form">
        <tr>
            <td colspan="6" class="interval">商场特殊信息</td>
        </tr>
        <tr>
            <th class="formTitle">行业/品牌/活动类型排他</th>
            <td class="formValue">
                <input id="exclusiveness" name="exclusiveness" type="text" maxlength="100" class="form-control" placeholder="请录入行业/品牌/活动类型排他" />
            </td>
            <th class="formTitle">起租天数</th>
            <td class="formValue">
                <input id="least_lease_days" name="least_lease_days" type="text" maxlength="50" class="form-control" placeholder="请录入起租天数" />
            </td>
            <th class="formTitle">是否存在双拼</th>
            <td class="formValue">
                <select id="pair" name="pair" class="form-control">
                    <option value="">==请选择是否存在双拼==</option>
                    <option value="是">是</option>
                    <option value="否">否</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="formTitle">商场定位：<span class="ISBT" style="color:red">*</span></td>
            <td class="formValue">
                <select id="F_StoreType" name="F_StoreType" multiple="multiple" class="form-control SCBT">
                    <option value="">==请选择==</option>
                </select>
            </td>
            <td class="formTitle">客群定位：<span class="ISBT" style="color:red">*</span></td>
            <td class="formValue">
                <select id="F_GuestType" name="F_GuestType" multiple="multiple" class="form-control SCBT">
                    <option value="">==请选择==</option>
                </select>
            </td>
            <td class="formTitle">商场人均消费：<span class="ISBT" style="color:red">*</span></td>
            <td class="formValue">
                <select id="F_Average_Consumer" name="F_Average_Consumer" class="form-control SCBT">
                    <option value="">==请选择==</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="formTitle">商场内品牌<span class="ISBT" style="color:red">*</span></td>
            <td class="formValue">
                <input id="sign_brand" name="sign_brand" maxlength="200" type="text" class="form-control SCBT " placeholder="多品牌请用/区分，例如 麦当劳/BOSS/优衣库 " />
            </td>
            <th></th>
            <td></td>
        </tr>
    </table>
</form>

<div style="margin-bottom:30px;">
    <table class="form" style="margin-top:10px;">
        <tr>
            <td colspan="6" class="interval">空间照片</td>
        </tr>

        <tr>
            <th class="formTitle">图片上传（支持多选批量上传）</th>
            <td class="formValue" colspan="2">
                <input id="PhotoFile" class="form-control" accept="image/*" type="file" name="filesf" multiple />
            </td>
            <td colspan="3">
                <input id="F_FilesBtn" onclick="uploadSend('PhotoFile','Space')" type="submit" value="上传图片" class="btn btn-primary" />
                <input id="Is_Down" onclick="checkIsDown()" value="批量下载" class="btn btn-primary" type="button" />
            </td>
        </tr>
        <tr>
            <td class="formValue" colspan="4" id="pList">
                <div id="photoList">
                </div>
            </td>
            <td colspan="2">
                <div id="displaydiv" style="display:none"></div>
                <p>
                    <span style="color:forestgreen">提示：</span>
                    此处需要您上传3-10张空间内部照片，空景照为佳，为保证您所上传的图片资料给到客户更好的展示效果，
                    请提供长宽比为4:3的常规横向展示照片，最小尺寸（790*526），如上传的图片不符合这一要求，我们将会默认裁剪为适合的显示比例。
                    图片要求清晰，单张最大不超过10MB
                </p>
            </td>
        </tr>
        <tr>
            <th class="formTitle">空间平面图</th>
            <td class="formValue" colspan="2">
                <input id="PlaneFile" class="form-control" accept="image/*" type="file" name="filesf" />
            </td>
            <td>
                <input id="F_PlaneFileBtn" onclick="uploadSend('PlaneFile','SpacePlaneFile')" type="button" value="上传平面图" class="btn btn-primary" />
            </td>
            <td colspan="2">
                <img src="" id="F_PlaneFile" width="100" height="100" alt="空间平面图" style="display:none" />
            </td>
        </tr>
    </table>
</div>

<div style="margin-bottom:50px;">
    <table class="form" style="margin-top:10px;">
        <tr>
            <td colspan="6" class="interval">其他资料</td>
        </tr>
        <tr>
            <th class="formTitle">资料上传（支持多选批量上传）</th>
            <td class="formValue" colspan="2">
                <input id="filesf" class="form-control" type="file" name="filesf" multiple />
            </td>
            <td>
                <input id="F_FilesBtn" onclick="uploadSend('filesf','SpaceFiles')" type="submit" value="上传资料" class="btn btn-primary" />
            </td>
            <td colspan="2">
                <p>
                    <span style="color:forestgreen">提示：</span>此处需要您上传有关该空间的相关平面图，吊点图，配电箱位置图等资资料
                </p>
            </td>
        </tr>
        <tr>
            <th class="formTitle"></th>
            <td colspan="3">
                <div id="imgrq"></div>
                <div id="imgrq1" style="margin-top:20px;"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">空间小视频（支持多选批量上传）</th>
            <td class="formValue" colspan="2">
                <input id="SpaceVideoFile" class="form-control" accept="video/*" type="file" name="SpaceVideoFile" multiple />
            </td>
            <td>
                <input id="F_VideoFilesBtn" onclick="uploadSend('SpaceVideoFile','SpaceVideo')" type="button" value="上传视频" class="btn btn-primary" />
            </td>
            <td colspan="2">
                <p>
                    <span style="color:forestgreen">提示：</span>此处可以上传一些有关场地的实景小视频，有助于客户更直观地了解您的场地，单个文件大小请控制在10MB以内
                </p>
            </td>
        </tr>
        <tr>
            <th></th>
            <td class="formValue" colspan="3">
                <div id="VideoList">
                </div>
            </td>
        </tr>
    </table>
</div>

<div></div>
<script src="http://vjs.zencdn.net/5.10.4/video.js"></script>

<script type="text/javascript">
    $('.clockpicker').clockpicker();
</script>
